package com.he.hsdyc.designmodule.observer;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能描述: 微信
 */
@Data
@Slf4j
public class Wechat implements ObserverNo {

    private List<Observer> observers;
    private String Message;

    public Wechat() {
        observers = new ArrayList<>();
    }

    @Override
    public void addObserver(Observer observer) {
          observers.add(observer);
    }

    @Override
    public void delObserver(Observer observer) {
        log.info("移除一个用户");
        observers.remove(observer);
    }

    @Override
    public void notifyAllServer(String message) {
        log.info("微信开始推送统一消息");
        observers.forEach(observer -> {
            observer.update(message);
        });
    }
}
